//
//  BasePageViewController.m
//  CatMusic
//
//  Created by dllo on 15/5/1.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "BasePageViewController.h"
#import "PlayerSingleton.h"
#import "MusicPlayViewController.h"

#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height

@interface BasePageViewController ()

@end

@implementation BasePageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // 设置右边按钮
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(rightButtonClick)];
   
    
}

- (void)rightButtonClick
{
    MusicPlayViewController *musicPlayVC = [[MusicPlayViewController alloc] init];
    if([PlayerSingleton sharePlayerSingleton].currentMusicListArr == nil)
    {
        NSArray *sandBox = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 1, YES);
        NSString *sandBoxPath = [sandBox lastObject];
        NSString *musicListPath = [sandBoxPath stringByAppendingPathComponent:@"musicList.plist"];
        NSMutableDictionary *musicListDic = [NSKeyedUnarchiver unarchiveObjectWithFile:musicListPath];
        NSString *index  = [musicListDic objectForKey:@"indexPath"];
        [PlayerSingleton sharePlayerSingleton].index = [index intValue];     // 将字符串转换成数字
        [PlayerSingleton sharePlayerSingleton].currentMusicListArr = [musicListDic objectForKey:@"modelArr"];
        NSLog(@"11%@", musicListPath);
    }
    musicPlayVC.modelArr = [PlayerSingleton sharePlayerSingleton].currentMusicListArr;
    musicPlayVC.indexPath = [PlayerSingleton sharePlayerSingleton].index;
    [self.navigationController pushViewController:musicPlayVC animated:YES];
    [musicPlayVC release];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
